<template>
    <div>
        <el-card class="box-card">
            <!-- 头部区域 -->
            <template #header>
                <div class="header">
                    <span>课程名称:&nbsp;&nbsp;{{ courseName }}</span>
                </div>
            </template>
            <!-- 课程信息-------------------------------------------------------------------------------------------------------- -->
            <el-tabs type="border-card">
                <el-tab-pane label="课程信息">
                    <el-descriptions :title=courseName>
                        <el-descriptions-item label="授课班级">{{ classMsg.classname }}</el-descriptions-item>
                        <el-descriptions-item label="课程开始时间">{{ course.startTime }}</el-descriptions-item>
                        <el-descriptions-item label="课程结束时间">{{ course.endTime }}</el-descriptions-item>
                        <el-descriptions-item label="备注">
                            {{ course.remark }}
                        </el-descriptions-item>
                    </el-descriptions>
                </el-tab-pane>
                <!-- 分数占比------------------------------------------------------------------------------------------------- -->
                <el-tab-pane label="课程分数占比设置">
                    <el-form :label-position="labelPosition" label-width="150px" :model="percentage" class="per"
                        :rules="rules">
                        <el-form-item label="出勤分数占比:" prop="attend">
                            <el-input v-model="percentage.attend"></el-input>
                        </el-form-item>
                        <el-form-item label="课堂任务分数占比:" prop="classtask">
                            <el-input v-model="percentage.classtask"></el-input>
                        </el-form-item>
                        <el-form-item label="课后任务分数占比:" prop="aftertask">
                            <el-input v-model="percentage.aftertask"></el-input>
                        </el-form-item>
                        <el-form-item label="实验报告分数占比:" prop="experiment">
                            <el-input v-model="percentage.experiment"></el-input>
                        </el-form-item>
                        <el-form-item label="平时分分数占比:" prop="usualscore">
                            <el-input v-model="percentage.usualscore"></el-input>
                        </el-form-item>
                        <el-form-item label="期末分数占比:" prop="finalscore">
                            <el-input v-model="percentage.finalscore"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button style="margin-left: 100px;" type="primary" @click="onSubmit">确认</el-button>
                            <el-button style="margin-left: 150px;" @click="onReset">重置</el-button>
                        </el-form-item>
                    </el-form>
                </el-tab-pane>
                <!-- 作业------------------------------------------------------------------------------------------------------ -->
                <el-tab-pane label="作业">
                    <!-- 搜索表单 -->
                    <el-form :inline="true" class="demo-form-inline">
                        <el-form-item label="作业标题:" style="margin-right: 20px;">
                            <el-input placeholder="作业标题" v-model="homeworkSearch.name"></el-input>
                        </el-form-item>
                        <el-form-item label="作业类型:">
                            <el-select placeholder="作业类型" v-model="homeworkSearch.type">
                                <el-option label="课堂任务" value="课堂任务"></el-option>
                                <el-option label="课后任务" value="课后任务"></el-option>
                                <el-option label="实验报告" value="实验报告"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" icon="el-icon-search" @click="getHomework">查询</el-button>
                            <el-button type="primary" icon="el-icon-refresh" @click="reset">重置</el-button>
                            <el-button type="primary" icon="el-icon-plus" @click="drawer = true">发布作业</el-button>
                        </el-form-item>
                    </el-form>
                    <!--表格  -->
                    <el-table :data="HtableData" style="width: 100%">
                        <el-table-column prop="name" label="作业标题" width="200px">
                        </el-table-column>
                        <el-table-column prop="type" label="作业类型" width="200px">
                        </el-table-column>
                        <el-table-column prop="content" label="作业内容" width="200px">
                        </el-table-column>
                        <el-table-column prop="stime" label="开始时间" width="200px">
                        </el-table-column>
                        <el-table-column prop="etime" label="截止时间" width="200px">
                        </el-table-column>
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <el-button slot="reference" type="success" icon="el-icon-view" size="small" circle
                                    @click="lookwork(scope.row.homeworkid, scope.row.classid)">
                                </el-button>
                                <el-button class="btn" type="primary" icon="el-icon-edit" circle size="small"
                                    @click="edit(scope.row)"></el-button>
                                <el-button slot="reference" type="danger" icon="el-icon-delete" size="small" circle
                                    @click="handleDelete(scope.row.homeworkid)"></el-button>



                            </template>

                        </el-table-column>
                        <template #empty>
                            <el-empty description="没有数据" />
                        </template>
                    </el-table>
                    <!-- 分页条 -->
                    <div class="block">
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                            :current-page="this.pageNum" :page-sizes="[5, 10, 15]" :page-size=this.pageSize
                            layout="total, sizes, prev, pager, next, jumper" :total=this.total>
                        </el-pagination>
                    </div>
                    <!-- 抽屉 -->
                    <el-drawer :title="title" :visible.sync="drawer" :direction="direction" class="addform">

                        <el-form ref="form" :model="homework" label-width="80px">

                            <el-form-item label="作业标题">
                                <el-input v-model="homework.name" placeholder="作业标题"></el-input>
                            </el-form-item>
                            <el-form-item label="作业类型">
                                <el-select placeholder="作业类型" v-model="homework.type">
                                    <el-option label="课堂任务" value="课堂任务"></el-option>
                                    <el-option label="课后任务" value="课后任务"></el-option>
                                    <el-option label="实验报告" value="实验报告"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="作业内容">
                                <el-input v-model="homework.content" placeholder="作业内容"></el-input>
                            </el-form-item>
                            <el-form-item label="开始时间">
                                <el-date-picker v-model="homework.stime" value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime" placeholder="选择日期">
                                </el-date-picker>
                            </el-form-item>
                            <el-form-item label="结束时间">
                                <el-date-picker v-model="homework.etime" value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime" placeholder="选择日期">
                                </el-date-picker>
                            </el-form-item>
                            <el-form-item>
                                <el-button type="primary" @click="homeworkAddUpdate">提交</el-button>
                                <el-button @click="drawer = false">取消</el-button>
                            </el-form-item>

                        </el-form>

                    </el-drawer>
                </el-tab-pane>


                <!-- 作业成绩---------------------------------------------------------------------------------------------------- -->
                <el-tab-pane label="作业成绩">
                    <!-- 搜索表单 -->
                    <el-form :inline="true" class="demo-form-inline">
                        <el-form-item label="学生姓名：">
                            <el-select v-model="workgradeSearch.stuid" placeholder="请选择学生姓名" prop="name">
                                <el-option v-for="s in stu" :key="s.stuid" :label="s.name" :value="s.stuid">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="作业类型">
                            <el-select placeholder="作业类型" v-model="workgradeSearch.type">
                                <el-option label="课堂任务" value="课堂任务"></el-option>
                                <el-option label="课后任务" value="课后任务"></el-option>
                                <el-option label="实验报告" value="实验报告"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" icon="el-icon-search" @click="getworkgrade">查询</el-button>
                            <el-button type="primary" icon="el-icon-refresh" @click="reset2">重置</el-button>
                        </el-form-item>
                    </el-form>
                    <!--表格  -->
                    <el-table id="gradeTable" :data="workgrade" style="width: 100%">
                        <el-table-column prop="name" label="学生姓名"></el-table-column>
                        <el-table-column prop="homeworkname" label="作业标题"></el-table-column>
                        <el-table-column prop="type" label="作业类型"></el-table-column>
                        <el-table-column prop="grade" label="分数"></el-table-column>
                        <template #empty>
                            <el-empty description="没有数据" />
                        </template>
                    </el-table>
                    <!-- 分页条 -->
                    <div class="block">
                        <el-pagination @size-change="SizeChange" @current-change="CurrentChange"
                            :current-page="this.wpageNum" :page-sizes="[5, 10, 15]" :page-size=this.wpageSize
                            layout="total, sizes, prev, pager, next, jumper" :total=this.wtotal>
                        </el-pagination>
                    </div>
                </el-tab-pane>
                <!-- 成绩------------------------------------------------------------------------------------------------------------------- -->
                <el-tab-pane label="成绩录入">
                    <!-- 搜索表单 -->
                    <el-form :inline="true" class="demo-form-inline">
                        <el-form-item label="学生姓名：">
                            <el-select v-model="gradeSearch.stuid" placeholder="请选择学生姓名" prop="name">
                                <el-option v-for="s in stu" :key="s.stuid" :label="s.name" :value="s.stuid">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <el-row style="display: flex;justify-content: inherit;">
                                <el-button type="primary" icon="el-icon-search" @click="getGrade">查询</el-button>
                                <el-button type="primary" icon="el-icon-refresh" @click="reset1">重置</el-button>
                                <el-button type="primary" icon="el-icon-plus" @click="drawer1 = true">成绩录入</el-button>
                                <download-excel :data="gradeData" :fields="json_fields" name="成绩单.xls"
                                    style="margin-left: 10px;">
                                    <el-button type="primary" icon="el-icon-upload">成绩导出</el-button>
                                </download-excel>
                            </el-row>
                        </el-form-item>
                    </el-form>
                    <!--表格  -->
                    <el-table id="gradeTable" :data="gradeData" style="width: 100%">
                        <el-table-column prop="gradeid" label="ID" width="110px"></el-table-column>
                        <el-table-column prop="name" label="学生姓名" width="110px"></el-table-column>
                        <el-table-column prop="attendNum" label="出勤" width="110px"></el-table-column>
                        <el-table-column prop="classtaskNum" label="课堂任务" width="110px"></el-table-column>
                        <el-table-column prop="aftertaskNum" label="课后任务" width="110px"></el-table-column>
                        <el-table-column prop="experimentNum" label="实验报告" width="110px"></el-table-column>
                        <el-table-column prop="usualscoreNum" label="平时分" width="110px"></el-table-column>
                        <el-table-column prop="finalscoreNum" label="期末考试" width="110px"></el-table-column>
                        <el-table-column prop="totalNum" label="课程总分" width="110px"></el-table-column>
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <!-- <el-dialog title="温馨提示！" :visible.sync="dialog" width="30%">
                                    <span>确定要删除这个学生成绩吗?</span>
                                    <span slot="footer" class="dialog-footer">
                                        <el-button @click="dialog = false">取 消</el-button>
                                        <el-button type="primary" @click="gradeDelete(scope.row.gradeid)">确
                                            定</el-button>
                                    </span>
                                </el-dialog> -->
                                <el-button class="btn" type="primary" icon="el-icon-edit" circle size="small"
                                    @click="gradeedit(scope.row)"></el-button>
                                <el-button slot="reference" type="danger" icon="el-icon-delete" size="small" circle
                                    @click="gradeDelete(scope.row.gradeid)"></el-button>
                            </template>
                        </el-table-column>
                        <template #empty>
                            <el-empty description="没有数据" />
                        </template>
                    </el-table>
                    <!-- 分页条 -->
                    <div class="block">
                        <el-pagination @size-change="ghandleSizeChange" @current-change="ghandleCurrentChange"
                            :current-page="this.gpageNum" :page-sizes="[5, 10, 15]" :page-size=this.gpageSize
                            layout="total, sizes, prev, pager, next, jumper" :total=this.gtotal>
                        </el-pagination>
                    </div>
                    <!-- 抽屉 -->
                    <el-drawer :title="title1" :visible.sync="drawer1" :direction="direction" class="addform">

                        <el-form ref="form" :model="grade" label-width="80px" :rules="graderules">
                            <el-form-item label="学生">
                                <el-select v-model="grade.stuid" placeholder="请选择学生姓名" prop="name">
                                    <el-option v-for="s in stu" :key="s.stuid" :label="s.name" :value="s.stuid">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="出勤" prop="attendNum">
                                <el-input v-model="grade.attendNum" placeholder="出勤分"></el-input>
                            </el-form-item>
                            <el-form-item label="课堂任务" prop="classtaskNum">
                                <el-input v-model="grade.classtaskNum" placeholder="课堂任务分"></el-input>
                            </el-form-item>
                            <el-form-item label="课后任务" prop="aftertaskNum">
                                <el-input v-model="grade.aftertaskNum" placeholder="课后任务分"></el-input>
                            </el-form-item>
                            <el-form-item label="实验报告" prop="experimentNum">
                                <el-input v-model="grade.experimentNum" placeholder="实验报告分"></el-input>
                            </el-form-item>
                            <el-form-item label="期末分数" prop="finalscoreNum">
                                <el-input v-model="grade.finalscoreNum" placeholder="期末分数"></el-input>
                            </el-form-item>
                            <el-form-item>
                                <el-button type="primary" @click="gradeaddORupdate">提交</el-button>
                                <el-button @click="drawer1 = false">取消</el-button>
                            </el-form-item>

                        </el-form>

                    </el-drawer>

                </el-tab-pane>
            </el-tabs>
        </el-card>
    </div>
</template>

<script>
import request from '@/utils/request';
export default {
    data() {
        return {
            //成绩模型
            grade: {
                gradeid: '',
                stuid: '',
                courseid: this.$route.query.courseId,
                classid: this.$route.query.classId,
                attendNum: '',
                classtaskNum: '',
                aftertaskNum: '',
                experimentNum: '',
                usualscore: 0,
                finalscoreNum: '',
                totalsocreNum: 0
            },
            //成绩搜索模型
            gradeSearch: {
                stuid: ''
            },
            //学生数据模型
            stu: {

            },
            //作业搜索模型
            homeworkSearch: {
                name: '',
                type: ''
            },
            //作业数据模型
            homework: {
                homeworkid: '',
                courseid: this.$route.query.courseId,
                classid: this.$route.query.classId,
                name: '',
                type: '',
                content: '',
                stime: '',
                etime: ''
            },
            //百分比校验规则
            rules: {
                attend: [{ validator: this.check, trigger: 'blur' },],
                classtask: [{ validator: this.check, trigger: 'blur' },],
                aftertask: [{ validator: this.check, trigger: 'blur' },],
                experiment: [{ validator: this.check, trigger: 'blur' },],
                usualscore: [{ validator: this.check, trigger: 'blur' },],
                finalscore: [{ validator: this.check, trigger: 'blur' },]
            },
            graderules: {
                attendNum: [{ validator: this.gradecheck, trigger: 'blur' },],
                classtaskNum: [{ validator: this.gradecheck, trigger: 'blur' },],
                aftertaskNum: [{ validator: this.gradecheck, trigger: 'blur' },],
                experimentNum: [{ validator: this.gradecheck, trigger: 'blur' },],
                finalscoreNum: [{ validator: this.gradecheck, trigger: 'blur' },]
            },
            //路由获取参数
            courseName: this.$route.query.courseName,
            courseId: this.$route.query.courseId,
            classId: this.$route.query.classId,
            labelPosition: 'right',
            drawer: false,
            drawer1: false,
            dialogVisible: false,
            dialog: false,
            direction: 'rtl',
            //成绩作业分页
            wpageNum: 1,
            wpageSize: 5,
            wtotal: 10,
            //作业分页
            pageNum: 1,
            pageSize: 5,
            total: 10,
            //成绩分页
            gpageNum: 1,
            gpageSize: 5,
            gtotal: 10,
            title: '发布作业',
            title1: '成绩录入',
            //成绩表格
            gradeData: [{
                gradeid: '',
                stuid: '',
                classid: '',
                courseid: '',
                name: '',
                classname: '',
                coursename: '',
                attendNum: '',
                classtaskNum: '',
                aftertaskNum: '',
                experimentNum: '',
                usualscoreNum: '',
                finalscoreNum: '',
                totalNum: ''
            }
            ],
            //作业表格
            HtableData: [],
            //作业成绩
            workgrade: [],
            //百分比数据模型
            percentage: {
                percentId: '',
                courseId: this.$route.query.courseId,
                classId: this.$route.query.classId,
                attend: '',
                classtask: '',
                aftertask: '',
                experiment: '',
                usualscore: '',
                finalscore: ''
            },
            //课程信息数据模型
            course: {
                courseName: '',
                name: '',
                startTime: '',
                endTime: '',
                remark: ''
            },
            //班级信息数据模型
            classMsg: {
                classname: ''
            },
            //w
            workgradeSearch: {
                stuid: '',
                type: ''
            },
            //导出
            json_fields: {
                学生姓名: "name",
                专业班级: "classname",
                课程: "coursename",
                出勤分数: "attendNum",
                课堂任务分数: "classtaskNum",
                课后任务分数: "aftertaskNum",
                实验报告分数: "experimentNum",
                平时分数: "usualscoreNum",
                期末分数: "finalscoreNum",
                课程总分: "totalNum"
            }

        }
    },

    methods: {
        //作业成绩查询
        getworkgrade() {
            request.get("/subwork/getgradeAll", {
                params: {
                    pageNum: this.wpageNum,
                    pageSize: this.wpageSize,
                    courseId: this.courseId,
                    classId: this.classId,
                    stuId: this.workgradeSearch.stuid,
                    type: this.workgradeSearch.type
                }
            }).then(res => {
                if (res.data.code == '0') {
                    this.workgrade = res.data.data.list
                    this.wtotal = res.data.data.total
                    console.log(this.workgrade)
                } else {
                    this.$message.error("获取失败")
                }
            })
        },
        //查询学生（班级id）
        stuSearch() {
            request.get("stu/findByclassid", {
                params: {
                    classId: this.classId
                }
            }).then(res => {
                if (res.data.code == '0') {
                    this.stu = res.data.data
                } else {
                    this.$message.error("获取失败")
                }
            })

        },



        //查询作业
        lookwork(homeworkid, classid) {
            this.$router.push({
                path: '/LookWork:homeworkId:classId',
                query: { homeworkId: homeworkid, classId: classid }
            });
        },
        //作业搜索重置
        reset() {
            this.homeworkSearch.name = '',
                this.homeworkSearch.type = ''
        },
        //成绩搜索条件重置
        reset1() {
            this.gradeSearch.stuid = ''
        },
        reset2() {
            this.workgradeSearch.stuid = '',
                this.workgradeSearch.type = ''
        },
        //作业信息删除
        handleDelete(id) {


            this.$confirm('是否删除此作业信息?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {

                request.delete("/homework/delete", {
                    params: {
                        id: id
                    }
                }).then(res => {
                    if (res.data.code == '0') {
                        this.$message.success("删除成功")
                        this.getHomework()
                    } else {
                        this.$message.error("删除失败")
                    }
                })

            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });

        },
        //成绩信息删除
        gradeDelete(id) {


            this.$confirm('是否删除此成绩?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {

                request.delete("/grade/delete", {
                    params: {
                        id: id
                    }
                }).then(res => {
                    if (res.data.code == '0') {
                        this.$message.success("删除成功")
                        this.getGrade()
                        this.dialog = false
                    } else {
                        this.$message.error("删除失败")
                    }
                })

            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });


        },
        //成绩数据模型情况
        cleanGrade() {
            this.grade.gradeid = '',
                this.grade.stuid = '',
                this.aftertaskNum = "",
                this.classtaskNum = "",
                this.attendNum = "",
                this.experimentNum = "",
                this.finalscoreNum = ""
        },
        //成绩 添加及修改
        gradeaddORupdate() {
            request.post("/grade/addORupdate", this.grade).then(res => {
                if (res.data.code == '0') {
                    this.$message.success("录入成功")
                    this.drawer1 = false
                    this.cleanGrade()
                    this.getGrade()
                } else {
                    console.log(res.data)
                    this.$message.error(res.data.message)
                }
            }).catch(error => {
                console.log(new error("服务异常"))
                this.$message.error("服务异常")
            })
        },
        //成绩修改
        gradeedit(obj) {
            this.title = "成绩修改",
                this.grade = obj;
            this.drawer1 = true
        },
        //获取成绩数据
        getGrade() {
            request.get("/grade/findAll", {
                params: {
                    pageNum: this.gpageNum,
                    pageSize: this.gpageSize,
                    classid: this.classId,
                    courseid: this.courseId,
                    stuid: this.gradeSearch.stuid,
                }
            }).then(res => {
                if (res.data.code == '0') {
                    this.gradeData = res.data.data.list
                    console.log(this.gradeData)
                    this.gtotal = res.data.data.total
                } else {
                    this.$message.error("获取成绩信息失败")
                }
            })
        },
        //作业编辑
        edit(obj) {
            this.title = "修改作业",
                this.homework = obj;
            this.drawer = true
        },
        //发布作业 新增和修改
        homeworkAddUpdate() {
            request.post("/homework/addORupdate", this.homework).then(res => {
                if (res.data.code == '0') {
                    this.$message.success("发布成功")
                    this.drawer = false
                    this.getHomework()
                } else {
                    this.$message.error("发布失败")
                }
            })
        },
        //获取作业数据
        getHomework() {
            request.get("/homework/findAll", {
                params: {
                    pageNum: this.pageNum,
                    pageSize: this.pageSize,
                    courseId: this.courseId,
                    classId: this.classId,
                    name: this.homeworkSearch.name,
                    type: this.homeworkSearch.type
                }
            }).then(res => {
                if (res.data.code == '0') {
                    this.HtableData = res.data.data.list
                    this.total = res.data.data.total
                } else {
                    this.$message.error("获取作业信息失败")
                }
            })
        },
        //作业成绩分页
        SizeChange(pageSize) {
            this.wpageSize = pageSize
            console.log(pageSize)
            this.getworkgrade()
        },

        CurrentChange(pageNum) {
            this.wpageNum = pageNum
            this.getworkgrade()
            console.log(pageNum)
        },
        //作业分页方法 
        handleSizeChange(pageSize) {
            this.pageSize = pageSize
            console.log(pageSize)
            this.getHomework()
        },

        handleCurrentChange(pageNum) {
            this.pageNum = pageNum
            this.getHomework()
            console.log(pageNum)
        },
        //成绩分页方法
        ghandleSizeChange(pageSize) {
            this.gpageSize = pageSize
            console.log(pageSize)
            this.getGrade()
        },
        ghandleCurrentChange(pageNum) {
            this.gpageNum = pageNum
            this.getGrade()
            console.log(pageNum)
        },
        //百分比校验
        check(rule, value, callback) {
            if (value < 0 || value > 1) {
                // 明确调用callback以处理错误情况
                callback(new Error('填写范围大于0,小于1!!!'));
            } else {
                // 如果验证通过，也需要调用callback，表示验证完成且无错误
                callback();
            }
        },
        //百分比校验
        gradecheck(rule, value, callback) {
            if (value > 100 || value < 0) {
                // 明确调用callback以处理错误情况
                callback(new Error('分数大于0,小于100'));
            } else {
                // 如果验证通过，也需要调用callback，表示验证完成且无错误
                callback();
            }
        },
        //获取百分比
        getPercentage() {
            request.get("/percentage/getByid", {
                params: {
                    courseId: this.$route.query.courseId,
                    classId: this.$route.query.classId,
                }
            }).then(res => {
                if (res.data.code == '0') {
                    console.log(res.data.data)
                    this.percentage = res.data.data
                } else {
                    this.$message.error("未设置分数占比!!!")
                }
            })
        },
        //百分比提交
        onSubmit() {
            request.post("/percentage/addORupdate", this.percentage).then(res => {
                if (res.data.code == '0') {
                    this.$message.success("提交成功")
                    console.log(res.data)
                } else {
                    this.$message.error(res.data)
                }
            })
        },
        //百分比重置
        onReset() {
            this.percentage.attend = '',
                this.percentage.classtask = '',
                this.percentage.aftertask = '',
                this.percentage.experiment = '',
                this.percentage.usualscore = '',
                this.percentage.finalscore = ''
        },
        //获取课程信息
        getCourseInfo() {
            request.get("/course/findByid", {
                params: {
                    id: this.$route.query.courseId
                }
            }).then(res => {
                if (res.data.code == '0') {
                    console.log(res.data.data)
                    this.course = res.data.data
                } else {
                    this.$message.error("获取课程信息失败")
                }
            })
        },
        //获取课程信息
        getClassInfo() {
            request.get("/class/getByid", {
                params: {
                    id: this.$route.query.classId
                }
            }).then(res => {
                if (res.data.code == '0') {
                    console.log(res.data.data)
                    this.classMsg = res.data.data
                } else {
                    this.$message.error("获取班级信息失败")
                }
            })
        }
    },

    created() {
        this.getCourseInfo()
        this.getClassInfo()
        this.getPercentage()
        this.getHomework()
        this.stuSearch()
        this.getGrade()
        this.getworkgrade()
    }

}
</script>

<style scoped lang="less">
.per {
    .el-input {
        width: 60%;
    }
}

.box-card {
    height: auto;
    background: whitesmoke;
}

.addform {
    .el-input {
        margin-left: 10px;
        width: 70%;
    }

    .el-select {
        margin-left: 10px;
        width: 70%;
    }

}
</style>